<template>
	<app-layout>
		<view v-if="!loading" class="u-goods-detail"></view>
		<template v-else>
			<app-goods-banner :isCart="false" :picList="detail.pic_url" :share="detail.share" sign="pintuan"
				:goods_id="goods_id" :video-url="detail.video_url"></app-goods-banner>
			<app-pt-time :theme="getTheme" :end_time="detail.pintuanGoods.end_time" :start_time="start_time"
				:time_str="time_str"></app-pt-time>
			<app-price-title-share :theme="getTheme" :groups="detail.groups" :title="detail.name"
				:subtitle="detail.subtitle" :price_min="detail.price_min" :isabuy="false"
				:is_vip_card_user="detail.vip_card_appoint.is_vip_card_user" :original_price="detail.original_price"
				:discount="discount" :level_show="detail.level_show" :share_url="share_url" :has-poster-nav="true"
				:poster-config="poster_config" :poster-generate="poster_generate"></app-price-title-share>

			<view class="goods-margin" v-if="detail.services.length > 0">
				<app-goods-service :list="detail.services" :guarantee_title="detail.guarantee_title"
					:guarantee_pic="detail.guarantee_pic"></app-goods-service>
			</view>
			<view class="goods-margin" @click="leabrand">
				<view class="u-service u-red cross-center">
					<view class="box-grow-0">线上线下完美合一的珠宝领导品牌</view>
					<view class="canmore">
						<text>查看更多</text>
						<image class="image" src="/static/image/icon/right.png"></image>
					</view>
				</view>
			</view>
			<!-- 如何获取优惠券 -->
			<view class="goods-margin" @click="voucher" v-if="detail.goods_coupon_center.length > 0">
				<view class="u-service cross-center">
					<view class="box-grow-0 u-text">如何获取优惠券</view>
					<image class="u-icon-del" src="/static/image/icon/arrow-right.png"></image>
				</view>
			</view>
			<view class="goods-margin" @click="route_go">
				<view class="u-service cross-center">
					<view class="box-grow-0 u-text">拼团规则</view>
					<image class="u-icon-del" src="/static/image/icon/arrow-right.png"></image>
				</view>
			</view>
			<u-attr :goods="detail" :checked="selectAttr" :themeObject="themeObject" @check="attrTap" v-model="show"
				:is_show_left="false" :is_show_right="false" ref="attr" :again="again" :ispt="pt"
				:goodsdetail="goodsde">
				<!-- <view class="" v-if="detail.pintuanGoods.isabbuy == 1" slot="extra">
					<view class="abbox">
						<text class="abname">选择商品</text>
						<view class="abcontent dir-left-wrap">
							<view class="ab-item" @click="abcheck(index)" v-for="(item,index) in abdata" :key="index"
								:class="changeanum == index ? 'abchecked ' + themeObject.back : 'abunchecked'">
								{{item.name}}
							</view>
						</view>
					</view>
				</view> -->
				<view v-if="pt === true" slot="extra">
					<app-pt-attr :groups="detail.groups" :selectGroupAttrId="selectGroupAttrId" :theme="getTheme">
					</app-pt-attr>
				</view>
				<!-- 选择规格 -->
				<!-- <view v-if="detail.type === 'goods' && goods.pintuanGoods.isabbuy == 1" class="goods-margin" slot="btn">
					<app-goods-attr @click.native="defaultRequest" :selectAttr="selectAttr"
						:attr-groups="detail.attr_groups" :attr="detail.attr">
					</app-goods-attr>
				</view> -->
				<template slot="right">
					<view class="u-pt-bottom dir-left-nowrap">
						<view @click="rightFunc" class="dir-top-nowrap cross-center main-center box-grow-1"
							style="color: #ffffff;"
							:class="getTheme === 'a' ? 'app-pt-button' : getTheme+ '-m-back ' + getTheme">
							<text class="price">{{groupPrice}}</text>
							<text class="app-text">{{detail.groups[0].groups.people_num}}人拼团</text>
						</view>
					</view>
				</template>
			</u-attr>
			<view class="goods-margin" v-if="detail.goods_coupon_center.length > 0">
				<app-goods-coupon :theme="getTheme" @change="setCoupon" :coupons="detail.goods_coupon_center">
				</app-goods-coupon>
			</view>
			<!-- 获取金币规则 -->
			<view class="goods-margin" @click="integral"
				v-if="detail.goods_marketing_award.integral && detail.goods_marketing_award.integral.title">
				<view class="u-service cross-center">
					<view class="box-grow-0 u-text">获取金币规则</view>
					<image class="u-icon-del" src="../../static/image/icon/arrow-right.png"></image>
				</view>
			</view>
			<view class="goods-margin">
				<app-goods-marketing :express="detail.express" :pickup="detail.goods_marketing.pickup"
					:shipping="detail.goods_marketing.shipping" :limit="detail.goods_marketing.limit"
					:coupon="detail.goods_marketing_award.coupon" :card="detail.goods_marketing_award.card"
					:balance="detail.goods_marketing_award.balance" :theme="getTheme"
					:integral="detail.goods_marketing_award.integral"></app-goods-marketing>
			</view>
			<view class="goods-margin">
				<app-participant @goJoin="goJoin" :theme="getTheme" :pintuan_list="pintuan_list"></app-participant>
			</view>
			<!-- 商品分类 -->
			<view class="clalist goods-margin" @click="tolist">
				<view class="dir-left-nowrap item">
					<view class="box-grow-0">
						<image class="avatar"
							:src="detail.catsall.pic_url != '' ? detail.catsall.pic_url : imgprefix + '/web/uploads/thumbs/mall1/20210628/ee56ff6d2fd02c27930d11a635ace256.jpg'">
						</image>
					</view>
					<view class="box-grow-1">
						<view class="name mb-8">{{detail.catsall.name}}</view>
					</view>
				</view>
				<view class="evaluate">
					<view class="main-right">
						宝贝描述<text class="red">高</text>
					</view>
					<view class="main-right eva-item">
						卖家服务<text class="red">高</text>
					</view>
					<view class="main-right eva-item">
						实体店服务<text class="red">高</text>
					</view>
				</view>
			</view>
			<view class="goods-margin">
				<app-goods-detail :goods="detail"></app-goods-detail>
			</view>

			<app-goods-recommend title="猜你喜欢" :sureCart="true" :theme="getTheme" :goods-list="like_list">
			</app-goods-recommend>

			<!--空格区域-->
			<view class="safe-area-inset-bottom u-bottom">
				<view class="u-bottom-height"
					:class="pintuan_list.length > 0 && full_reduce ? 'u-bottom-height-1' : 'u-bottom-height-0'"></view>
			</view>
			<!--底部按钮-->
			<view class="safe-area-inset-bottom  u-bottom-fixed">
				<view v-if="full_reduce && !show">
					<app-goods-full-reduce :theme="getTheme" :full_reduce="full_reduce">
					</app-goods-full-reduce>
				</view>
				<view class="join dir-left-nowrap cross-center main-between" v-if="pintuan_list.length > 0 && !show">
					<view class="dir-left-nowrap cross-center">
						<image class="avatar" :src="pintuan_list[0].avatar"></image>
						<view class="text">剩余
							<text style="color: #ff4544;">{{pintuan_list_time}}</text>
							，还差{{pintuan_list[0].surplus_people}}人
							<text v-if="pintuan_list[0].is_abbuy == 1">,{{pintuan_list[0].abbuy_type}}商品可拼</text>
						</view>
					</view>
					<view :class="getTheme+ '-m-back btn ' + getTheme" @click="goJoin(pintuan_list[0].id)">参与拼团</view>
				</view>
				<app-button-button :level_show="detail.level_show" :member_price_min="detail.groups[0].member_price_min"
					:catsall="detail.catsall" :kefu="kefu" :groups="detail.groups" :pintuan_groups="item.pintuan_groups"
					:isabuy="detail.pintuanGoods.isabbuy == 1 ? true : false" :price="price"
					:price_member_min="detail.price_member_min" :pintuanList="pintuan_list"
					:is_alone_buy="detail.pintuanGoods.is_alone_buy" :selectGroupAttrId="selectGroupAttrId"
					:selectAttr="selectAttr" :pt="pt" :item="detail" @click="shop" :start_time="start_time"
					:theme="getTheme"></app-button-button>
			</view>

			<view class="quick-box" @click="tostore">
				规划4500家实体店
			</view>
		</template>
	</app-layout>
</template>
<script>
	import {
		mapGetters,
		mapState
	} from 'vuex';
	import appGoodsBanner from '../../../components/page-component/goods/app-goods-banner.vue';
	import appPtTime from '../components/app-pt-time.vue';
	import appPriceTitleShare from '../components/app-price-title-share.vue';
	import appJoinMember from '../../../components/page-component/app-join-member/app-join-member.vue';
	import appMerchantGuarantee from '../components/app-merchant-guarantee.vue';
	import appGoodsAttr from '../../../components/page-component/goods/app-goods-attr.vue';
	import appButtomButton from '../components/app-buttom-button.vue';
	import appPtAttr from '../components/app-pt-attr.vue';
	import appParticipant from '../components/app-participant.vue';
	import appRelatedSuggestionProduct from '../../../components/page-component/app-related-suggestion-product/app-related-suggestion-product.vue';
	import appGoodsRecommend from "../../../components/page-component/app-goods-recommend/app-goods-recommend.vue";
	import appGoodsDetail from '../../../components/page-component/goods/app-goods-detail.vue';
	import appQuickNavigation from "../../../components/page-component/app-quick-navigation/app-quick-navigation.vue";
	import appGoodsService from '../../../components/page-component/goods/app-goods-service.vue';
	import appGoodsMarketing from '../../../components/page-component/goods/app-goods-marketing.vue';
	import appGoodsFullReduce from "../../../components/page-component/goods/app-goods-full-reduce";
	import appGoodsCoupon from "../../../components/page-component/goods/app-goods-coupon.vue";
	import uAttr from '../../../components/page-component/goods/u-attr.vue';

	export default {
		name: 'goods',
		data() {
			return {
				goods_id: 0,
				detail: {
					goods_activity: {
						full_reduce: {}
					},
					groups: []
				},
				goodsde: '',
				full_reduce: null,
				loading: false,
				// 分享
				share_url: '',
				// 倒计时
				time_str: {
					day: '00',
					hou: '00',
					min: '00',
					sec: '00'
				},
				down_time: 0,
				// 超级会员功能
				discount: null,
				is_vip: false,
				goods: {},
				item: {
					name: '',
					pintuan_groups: [],
				},
				selectAttr: null,
				show: false,
				pt: false,
				selectGroupAttrId: 0,
				pintuan_list: [],
				// list: [],
				like_list: null,
				cartShow: false,
				price: '',
				time: null,
				is_vip_card_user: 0,
				url: this.$api.pt.detail,
				poster_config: this.$api.pt.poster_config,
				poster_generate: this.$api.pt.poster_generate,
				aloneAttr: null,
				allPriceAttr: null,
				start_time: false,
				pintuan_list_time: '',
				pt_time: null,
				number: 1,
				group_price: '',
				again: 0,
				/* abdata: [{
						name: "A"
					},
					{
						name: "B"
					}
				], */
				changeanum: 0,
				abbuy_type: 'A',
				// 去拼团的apptype
				cabbuy_type: 'A',
				// 门店列表
				storelist: [],
				longitude: '',
				latitude: '',
				firstGoodsId: null,
				kefu: ''
			}
		},
		computed: {
			...mapState('gConfig', {
				iphone: (data) => {
					return data.iphone;
				},
				iphoneHeight: (state) => {
					return state.iphoneHeight;
				},
			}),
			...mapGetters('iPhoneX', {
				BotHeight: 'getBotHeight',
				emptyHeight: 'getEmpty',
			}),
			...mapState({
				mall: state => state.mallConfig.mall
			}),
			...mapGetters('mallConfig', {
				getTheme: 'getTheme',
			}),
			themeObject: function() {
				return {
					back: this.getTheme + '-m-back ' + this.getTheme,
					theme: this.getTheme,
					color: this.getTheme + '-m-text ' + this.getTheme,
					sBack: this.getTheme + '-s-back ' + this.getTheme
				}
			},
			set_group_num() {
				for (let i = 0; i < this.detail.groups.length; i++) {
					if (this.detail.groups[i].groups.id == this.selectGroupAttrId) {
						return i;
					}
				}
			},
			// 拼团价格定金
			groupPrice: function() {
				if (this.pt) {
					if (!this.$validation.isEmpty(this.selectAttr)) {
						if (this.detail.level_show === 1) {
							if (this.selectAttr.price_member === 0) {
								return '免费';
							} else {
								return `￥${this.selectAttr.price_member}`;
							}
						} else {
							if (Number(this.selectAttr.price) === 0) {
								return '免费';
							} else {
								return `￥${this.selectAttr.price}`;
							}
						}
					} else {
						let attr = this.detail.groups[this.set_group_num].attr;
						for (let i = 0; i < attr.length; i++) {
							if (attr[i].sign_id === this.selectAttr.sign_id) {
								if (this.detail.level_show === 1) {
									if (attr[i].price_member === 0) {
										return '免费';
									} else {
										return `￥${attr[i].price_member}`;
									}
								} else {
									if (Number(attr[i].price) === 0) {
										return '免费';
									} else {
										return `￥${attr[i].price}`;
									}
								}
							}
						}
					}
				} else {
					let attr = this.detail.groups[0].attr;
					if (attr[0].price == 0) {
						return '免费';
					} else {
						return `￥${attr[0].price}`;
					}
				}
			},
			// 单独价格
			singlePrice: function() {
				// 一人购买两件定金
				if (this.detail.level_show === 1) {
					if (Number(this.detail.groups[0].attr[this.aloneAttr.length - 1].price_member) === 0) {
						return '免费';
					} else {
						return `￥${this.detail.groups[0].attr[this.aloneAttr.length - 1].price_member}`;
					}
				} else {
					if (Number(this.detail.groups[0].attr[this.aloneAttr.length - 1].price) === 0) {
						return '免费';
					} else {
						return `￥${this.detail.groups[0].attr[this.aloneAttr.length - 1].price}`;
					}
				}
			}
		},
		onLoad(options) {
			debugger;
			this.goods_id = options.goods_id;
			// this.requestDetail();

			this.loadLike();
			this.kefu = this.$storage.getStorageSync('KEFU')
			// #ifdef MP-WEIXIN
			wx.showShareMenu({
				menus: ['shareAppMessage', 'shareTimeline']
			})
			// #endif
		},
		onShow() {
			this.requestDetail();
		},

		onShareAppMessage() {
			return this.$shareAppMessage({
				path: '/plugins/pt/goods/goods',
				title: this.detail.app_share_title ? this.detail.app_share_title : this.detail.name,
				imageUrl: this.detail.app_share_pic ? this.detail.app_share_pic : '',
				params: {
					goods_id: this.goods_id
				}
			});
		},
		// #ifdef MP-WEIXIN
		onShareTimeline() {
			// 分享朋友圈beta
			return this.$shareTimeline({
				title: this.detail.app_share_title ? this.detail.app_share_title : this.detail.name,
				query: {
					goods_id: this.goods_id
				} // 此处填写页面的参数
			});
		},
		// #endif
		methods: {
			abcheck(id) {
				this.changeanum = id
				// this.abbuy_type = this.abdata[id].name
			},
			leabrand() {
				uni.navigateTo({
					url: '/pages/video/videodetail/videodetail?id=20&title=' + '线上线下完美合一的珠宝领导品牌'
				})
			},
			goJoin(id) {
				if (this.$store.state.user.accessToken === '' || this.$store.state.user.accessToken === null) {
					this.$store.dispatch('user/accessToken');
				} else {
					uni.navigateTo({
						url: `/plugins/pt/detail/detail?id=${id}`,
					});
				}
			},
			// 获取商品详情
			async requestDetail() {
				const e = await this.$request({
					url: this.$api.pt.detail,
					method: 'get',
					data: {
						id: this.goods_id,
					}
				});
				if (e.code === 0) {
					this.loading = true;
					let detail = e.data.detail;
					this.detail = detail;
					this.goodsde = e.data.detail
					// this.price = detail.price_max;
					// 全款
					this.price = detail.attr[detail.attr.length - 1].price;
					// 规格初始化
					// 全款
					this.allPriceAttr = JSON.parse(JSON.stringify(detail.attr));
					// 预付
					let groups = detail.groups;
					// 将groups的内容赋值给attr
					if (groups.length > 0) {
						this.detail.attr = groups[0].attr;
						this.selectGroupAttrId = groups[0].groups.id;
					}
					// 定金
					this.aloneAttr = JSON.parse(JSON.stringify(groups[0].attr));
					if (detail.goods_activity) {
						this.full_reduce = detail.goods_activity.full_reduce;
					}
					this.share_url = `${this.$api.pt.poster}&goods_id=${this.detail.id}`;
					this.poster_config = `${this.poster_config}&goods_id=${this.detail.id}`;
					this.poster_generate = `${this.poster_generate}&goods_id=${this.detail.id}`;
					// 拼团列表
					this.pintuan_list = e.data.pintuan_list;
					if (this.pintuan_list.length > 0) {
						let timelog = new Date(this.pintuan_list[0].surplus_date_time.replace(/-/g, '/'));
						this.pt_time = setInterval(() => {
							let time = timelog.getTime() - new Date().getTime();
							if (time < 0) {
								clearInterval(this.pt_time);
							}
							let day = parseInt((time / 1000 / 60 / 60 / 24) % 30);
							let hou = parseInt((time / 1000 / 60 / 60) % 24);
							let min = parseInt((time / 1000 / 60) % 60);
							let sec = parseInt((time / 1000) % 60);
							if (day > 0) {
								this.pintuan_list_time = day + "天" + hou + ":" + (min < 10 ? "0" + min : min) +
									":" + (sec < 10 ? "0" + sec : sec);
							} else {
								this.pintuan_list_time = hou + ":" + (min < 10 ? "0" + min : min) + ":" + (
									sec < 10 ? "0" + sec : sec);
							}
						}, 1000);
					}
					/* if (detail.vip_card_appoint.discount) {
						this.is_vip = true;
						this.discount = detail.vip_card_appoint.discount;
					} */

					this.goods = {
						attr: detail.attr,
						cover_pic: detail.cover_pic,
						level_show: detail.level_show,
						price: detail.price,
						mch_id: detail.mch_id
					};
					if (detail.pintuanGoods.end_time !== '0000-00-00 00:00:00') {
						this.countdown(detail.pintuanGoods.end_time);
					}

					if (detail.pintuanGoods.start_time) {
						let time = new Date(detail.pintuanGoods.start_time.replace(/-/g, '/'));
						let nowTime = new Date();
						let equation = time.getTime() - nowTime.getTime();
						if (equation > 0) {
							this.start_time = false;
							this.countdown(detail.pintuanGoods.start_time);
						} else {
							this.start_time = true;
						}
					}
				} else {
					uni.showToast({
						title: e.msg,
						icon: 'none'
					})
				}
				// this.newRecommend();
			},
			countdown(t) {
				let time = new Date(t.replace(/-/g, '/'));
				let nowTime = new Date();
				let equation = time.getTime() - nowTime.getTime();
				let day = parseInt((equation / 3600000 / 24));
				let hour = parseInt((equation / 1000 / 60 / 60) % 24);
				let minute = parseInt((equation / 1000 / 60) % 60);
				let second = parseInt((equation / 1000) % 60);
				this.time_str = {
					day: day < 10 ? `0${day}` : day,
					hou: hour < 10 ? `0${hour}` : hour,
					min: minute < 10 ? `0${minute}` : minute,
					sec: second < 10 ? `0${second}` : second
				}
				this.down_time = setTimeout(() => {
					this.countdown(t);
				}, 1000);
			},

			// 猜你喜欢
			loadLike() {
				this.$request({
					url: this.$api.goods.randow,
					data: {
						cat_id: 184,
						page: 8,
						mch_id: 0,
						sort: 1
					}
				}).then(response => {
					if (response.code === 0) {
						this.like_list = response.data.list;
					}
				});
			},
			voucher() {
				uni.navigateTo({
					url: '/pages/video/explain/explain?id=20&title=' + '如何获取优惠券'
				})
			},
			route_go() {
				uni.navigateTo({
					url: `/pages/rules/index?url=${encodeURIComponent(this.$api.pt.index)}&keys=${JSON.stringify(['setting', 'new_rules'])}`,
				});
			},
			integral() {
				uni.navigateTo({
					url: '/pages/video/explain/explain?id=30&title=' + '获取金币规则'
				})
			},
			tostore() {
				/* uni.navigateTo({
					url: '/pages/order-submit/store-pick?isshow=true'
				}) */
				uni.navigateTo({
					url: '/pages/turnover/videolist?type=20&title=实体店'
				})
			},
			tolist() {
				uni.navigateTo({
					url: `/plugins/pt/index/index?cat_id=${this.detail.catsall.id}&title=${this.detail.catsall.name}`
				});
			},
			setCoupon() {
				this.$set(this.detail.goods_coupon_center[index], 'is_receive', 1);
			},
			attrTap(data, number) {
				for (let i = 0; i < this.aloneAttr.length; i++) {
					if (this.aloneAttr[i].sign_id === data.sign_id) {
						this.price = this.aloneAttr[i].price;
					}
				}
				this.number = number;
				this.selectAttr = data;
			},
			shop(data) {
				if (data === true) {
					this.$set(this, 'pt', true);
					// if(this.detail.pintuanGoods.isabbuy == 1){
					this.selectGroupAttrId = this.detail.groups[0].group_id
					// }
					this.detail.groups.forEach((item) => {
						if (this.selectGroupAttrId === item.groups.id) {
							this.$set(this.detail, 'attr', item.attr);
							this.$set(this.detail, 'id', item.groups.goods_id);
						}
					});
					this.$nextTick(() => {
						this.$refs.attr.firstSelect();
					});
				} else {
					this.$set(this, 'pt', false);
					this.selectGroupAttrId = this.detail.groups[0].group_id

					/* this.$set(this.detail, 'attr', this.aloneAttr);
					this.$set(this.detail, 'id', this.goods_id); */
					// this.$set(this, 'pt', false);
					// this.$set(this.detail, 'attr', this.aloneAttr);
					// this.$set(this.detail, 'id', this.goods_id);
					/* console.log(this.detail);
					console.log(this.aloneAttr);
					console.log(this.goods_id); */
				}
				this.show = true;
			},
			/* setGroupAttrID(item) {
				// console.log(item);
				this.selectGroupAttrId = item.groups.id;
				this.$set(this.detail, 'attr', item.attr);
				this.$set(this.detail, 'id', item.groups.goods_id);
				this.$nextTick(() => {
					this.again = Math.random();
				});
			}, */
			defaultRequest() {
				this.$set(this, 'pt', true);
				this.detail.attr = this.detail.groups[0].attr;
				this.selectGroupAttrId = this.detail.groups[0].groups.id;
				this.detail.id = this.detail.groups[0].groups.goods_id;
			},
			rightFunc() {
				// 点击切换拼团
				if (this.$store.state.user.accessToken === '' || this.$store.state.user.accessToken === null) {
					this.$store.dispatch('user/accessToken');
					return;
				}
				if (this.detail.type === 'ecard') {
					uni.showToast({
						title: '虚拟商品不允许加入购物车',
						icon: 'none'
					});
					return;
				}
				if (this.pt === false && this.show === true) {
					this.pt = true;
					this.$set(this, 'pt', true);
					setTimeout(() => {
						this.show = true;
					}, 500);
					this.detail.groups.forEach((item) => {
						if (this.selectGroupAttrId === item.groups.id) {
							this.$set(this.detail, 'attr', item.attr);
							this.$set(this.detail, 'id', item.groups.goods_id);
						}
					});
					this.$nextTick(() => {
						this.again = Math.random();
					});
				} else {
					let attrs = [];
					this.selectAttr.attr_list.forEach(item => {
						attrs.push({
							attr_id: item.attr_id,
							attr_group_id: item.attr_group_id
						});
					});
					let newData = {
						pintuan_order_id: 0,
						pintuan_group_id: this.selectGroupAttrId,
						mch_id: this.detail.mch_id ? this.detail.mch_id : 0,
						goods_list: [{
							id: this.detail.id,
							attrs,
							num: this.number,
							cat_id: 0,
							goods_attr_id: this.selectAttr.id
						}]
					}
					if (this.detail.pintuanGoods.isabbuy == 0) {
						this.$jump({
							open_type: 'navigate',
							// 修改跳转
							url: `/pages/order-submit/order-submit?mch_list=${JSON.stringify([newData])}&preview_url=${encodeURIComponent(this.$api.pt.order_preview)}&submit_url=${encodeURIComponent(this.$api.pt.order_submit)}`
						});
					}
				}

			},
			leftFunc(number) {
				// 点击切换一人购买两件商品
				if (this.$store.state.user.accessToken === '' || this.$store.state.user.accessToken === null) {
					this.$store.dispatch('user/accessToken');
					return;
				}
				if (this.pt === true && this.show === true) {
					this.$set(this, 'pt', false);
					setTimeout(() => {
						this.show = true;
					}, 500);
					// this.$set(this.detail, 'attr', this.aloneAttr);
					this.$set(this.detail, 'attr', this.detail.groups[0].attr);
					this.$set(this.detail, 'id', this.goods_id);
					/* this.$nextTick(() => {
						this.$refs.attr.firstSelect();
					}); */
					// console.log(this.pt);
				} else {
					let goods = this.detail;
					let select_attr = this.selectAttr;
					let attr = [];
					// console.log(select_attr.attr_list);
					/* for (let i in select_attr.attr_list) {
						attr.push({
							attr_id: select_attr.attr_list[i].attr_id,
							attr_group_id: select_attr.attr_list[i].attr_group_id
						});
					} */
					attr.push({
						attr_id: this.aloneAttr[this.aloneAttr.length - 1].attr_list[0].attr_id,
						attr_group_id: this.aloneAttr[this.aloneAttr.length - 1].attr_list[0].attr_group_id
					});
					let mch_list = [{
						mch_id: goods.mch_id ? goods.mch_id : 0,
						pintuan_order_id: 0,
						pintuan_group_id: 0,
						goods_list: [{
							id: goods.id,
							attr: attr,
							num: number,
							cat_id: 0,
							goods_attr_id: select_attr.id
						}],
					}];
					uni.navigateTo({
						url: `/pages/order-submit/order-submit?mch_list=${JSON.stringify(mch_list)}&preview_url=${encodeURIComponent(this.$api.pt.order_preview)}&submit_url=${encodeURIComponent(this.$api.pt.order_submit)}&abbuy_type=AB`
					});
				}
			}
		},

		components: {
			'app-goods-banner': appGoodsBanner,
			'app-pt-time': appPtTime,
			'app-price-title-share': appPriceTitleShare,
			'app-join-member': appJoinMember,
			'app-merchant-guarantee': appMerchantGuarantee,
			'app-goods-attr': appGoodsAttr,
			'app-button-button': appButtomButton,
			'app-pt-attr': appPtAttr,
			'app-participant': appParticipant,
			'app-related-suggestion-product': appRelatedSuggestionProduct,
			'app-goods-detail': appGoodsDetail,
			'app-quick-navigation': appQuickNavigation,
			'app-goods-service': appGoodsService,
			'app-goods-marketing': appGoodsMarketing,
			appGoodsCoupon,
			uAttr,
			appGoodsFullReduce,
			appGoodsRecommend
		},
		onHide() {
			this.show = false
			clearTimeout(this.down_time);
		},
		onUnload() {
			clearTimeout(this.down_time);
		}
	}
</script>
<style lang="scss" scoped>
	.abbox {
		margin: 24upx 32upx 0 32upx;
		border-bottom: 1upx solid #e2e2e2;
	}

	.abname {
		font-size: 26upx;
		color: #666666;
		margin-bottom: 20upx;
	}

	.ab-item {
		padding: 15upx 24upx;
		border-radius: 8upx;
		margin: 0 20upx 20upx 0;
		font-size: 26upx;
	}

	.abchecked {
		color: #FFFFFF;
	}

	.abunchecked {
		background-color: #f2f2f2;
		color: #353535;
	}

	.vip-card {
		padding: 0 #{20rpx} #{20rpx};
		background-color: #fff;
	}

	.join-member {
		background-color: #ffffff;
		padding: 0 #{24rpx};
		box-sizing: border-box;
	}

	.app-buttons {
		position: fixed;
		z-index: 1602;
	}

	.join {
		width: 750upx;
		height: 88upx;
		background-color: #fff7b8;
		padding: 0 24upx;

		.avatar {
			width: 64upx;
			height: 64upx;
			border-radius: 32upx;
		}

		.btn {
			width: 160upx;
			height: 64upx;
			border-radius: 40upx;
			font-size: 26upx;
			color: #ffffff;
			line-height: 64upx;
			text-align: center;
		}

		.text {
			font-size: 26upx;
			margin-left: 24upx;
			line-height: 1;
			color: #353535;
		}
	}

	.u-bottom-fixed {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		z-index: 1500;
		background-color: #ffffff;
	}

	.u-bottom-height-0 {
		height: 190upx;
	}

	.u-bottom-height-1 {
		height: 280upx;
	}

	.goods-margin {
		margin-top: 20upx;
	}

	// 本频道
	.clalist {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: #{24rpx};
		background: #FFFFFF;

		.item {
			padding: #{24rpx};
			display: flex;
			align-items: center;

			.avatar {
				width: 100rpx;
				height: 100rpx;
				margin-right: #{24rpx};
				border-radius: #{999rpx};
				box-shadow: 0 0 #{1rpx} rgba(0, 0, 0, .25);
			}

			.name {
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
			}
		}

		.evaluate {
			font-size: 24rpx;

			.eva-item {
				margin: 12rpx 0 0;
			}

			.red {
				margin-left: 12rpx;
				color: #EB5757;
			}
		}
	}

	// 本频道推荐
	.app-goods-recommend {
		margin-top: 20upx;
		background-color: #FFFFFF;

		.recommend-title {
			padding: 40rpx 24rpx 32rpx;
			font-size: 32rpx;

			.text {
				color: #333;
			}

			.more {
				font-size: 28rpx;
				color: #666666;
			}
		}

		.recommend-list {
			.rec-item {
				width: 224rpx;
				margin: 0 15rpx 16rpx 0;
				border-radius: 16rpx;
				border: 1rpx solid #e2e2e2;

				.image {
					width: 224upx;
					height: 224upx;
				}
			}
		}
	}

	// 门店列表
	.list {
		.item {
			padding: #{24rpx};
			background: #fff;
			border-bottom: #{1rpx} solid $uni-weak-color-one;

			.avatar {
				width: #{140rpx};
				height: #{140rpx};
				margin-right: #{24rpx};
				border-radius: #{999rpx};
				box-shadow: 0 0 #{1rpx} rgba(0, 0, 0, .25);
			}

			.name {
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
			}

			.mobile,
			.distance {
				font-size: $uni-font-size-general-one;
				color: $uni-general-color-two;
			}
		}
	}

	// 如何获取抵用券
	.u-service {
		height: 100upx;
		background-color: #fff;
		font-size: 26upx;
		padding: 0 24upx;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.u-red {
		color: #fe0000;
		font-size: 32rpx;
		font-weight: bold;

		.canmore {
			width: 175rpx;
			height: 44rpx;
			border-radius: 60rpx;
			background: #ed9196;
			font-size: 24rpx;
			line-height: 44rpx;
			padding: 0 24rpx;
			color: #332d24;
			display: inline-flex;
			align-items: center;
			justify-content: space-around;
		}

		.image {
			width: 12upx;
			height: 22upx;
		}
	}

	.u-text {
		color: #999999;
	}

	.u-icon-del {
		width: 12upx;
		height: 22upx;
		display: block;
	}

	.ecard-text {
		color: #999999;
	}

	.descgoods {
		background-color: #FFFFFF;
		font-size: 24rpx;
		padding: 32rpx 24rpx;
		color: #666666;
	}

	.u-pt-bottom {
		width: 750rpx;
		height: 110rpx;
	}

	.app-pt-button {
		background: linear-gradient(140deg, #ff9460, #ff5c5c);

		text {
			color: white;
		}
	}

	.app-single-button {
		background-color: #feeeee;

		text {
			color: #ff5c5c;
		}
	}

	// 实体店
	.quick-box {
		position: fixed;
		right: 48rpx;
		z-index: 100;
		bottom: 316rpx;
		width: 100rpx;
		height: 150rpx;
		overflow: hidden;
		border-radius: 10rpx;
		background: #FFFFFF;
		font-size: 24rpx;
		line-height: 50rpx;
		text-align: center;
		border: 1rpx solid #ccc;
		color: #ff2f2f;
	}
</style>
